<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
        #empTable {
            margin: 0 auto;
            border: 1px solid antiquewhite;
            width: 80%;
        }

        #empTable th, td {
            border: 1px solid bisque;
            text-align: center;
        }

    </style>
</head>
<body>
<table id="empTable" cellpadding="0px" cellspacing="0px">
    <tr>
        <th>索引</th>
        <th>员工编号</th>
        <th>姓名</th>
        <th>职位</th>
        <th>上级</th>
        <th>入职日期</th>
        <th>薪水</th>
        <th>奖金</th>
        <th>部门编号</th>
        <th>操作</th>
    </tr>

    <tr th:each="emp,i:${empList}">
        <td th:text="${i.index + 1}"></td>
        <td th:text="${emp.empno}"></td>
        <td th:text="${emp.ename}"></td>
        <td th:text="${emp.job}"></td>
        <td th:text="${emp.mgr}"></td>
        <td th:text="${!#strings.isEmpty(emp)?#dates.format(emp.hiredate,'yyyy-MM-dd'):''}"></td>
        <td th:text="${emp.sal}" th:style="${emp.sal} ne null and ${emp.sal} gt 2000? 'color:red':''"></td>
        <td th:text="${emp.comm}"></td>
        <td th:text="${emp.deptno}"></td>
        <!--        <td><a th:href="@{deleteEmpByNoAndName(empno=${emp.empno},ename=${emp.ename})}">删除</a></td>-->
        <td><a href="javascript:void(0)" th:onclick="removeEmpByNoAndName([[${emp.empno}]],[[${emp.ename}]])">删除</a>
        </td>
    </tr>
</table>

httpServletRequest:
<span th:text="${#httpServletRequest.getAttribute('msg')}"></span>
<span th:text="${#request.getAttribute('msg')}"></span>
<hr/>

httpSession:
<span th:text="${#httpSession.getAttribute('msg')}"></span>
<span th:text="${#session.getAttribute('msg')}"></span>
<span th:text="${session.msg}"></span>
<hr/>

servletContext:
<span th:text="${#servletContext.getAttribute('msg')}"></span>
<span th:text="${application.msg}"></span>
<hr/>


<script>
    function removeEmpByNoAndName(empno, ename) {
        var ret = confirm("确定删除员工编号为：" + empno + "的" + ename)
        if (ret) {
            window.location.href = "deleteEmpByNoAndName?empno=" + empno + "&ename=" + ename
        }
    }
</script>
</body>
</html>